* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #2196F3;
  --success-color: #4CAF50;
  --error-color: #f44336;
  --warning-color: #ff9800;
  --bg-color: #f5f5f5;
  --text-color: #333;
  --border-color: #ddd;
  --shadow: 0 2px 8px rgba(0,0,0,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 768px;
  margin: 0 auto;
  background: white;
}

/* 连接面板 */
.connection-panel {
  padding: 12px 16px;
  background: white;
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
  font-weight: 500;
}

.status-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--error-color);
  transition: background-color 0.3s;
}

.status-indicator.connected .status-dot {
  background-color: var(--success-color);
}

.status-indicator.connecting .status-dot {
  background-color: var(--warning-color);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.connection-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

#serverAddress {
  flex: 1;
  min-width: 200px;
  padding: 10px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.3s;
}

#serverAddress:focus {
  outline: none;
  border-color: var(--primary-color);
}

.btn-connect, .btn-scan {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s;
  min-height: 44px;
}

.btn-connect {
  background-color: var(--primary-color);
  color: white;
}

.btn-connect:hover {
  background-color: #1976D2;
}

.btn-connect:active {
  transform: scale(0.98);
}

.btn-scan {
  background-color: white;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
}

.btn-scan:hover {
  background-color: #E3F2FD;
}

/* PPT预览区域 */
.preview-container {
  flex: 0 0 33.333%;
  background: #000;
  position: relative;
  overflow: hidden;
}

.slide-preview {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

#previewImage {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: none;
}

#previewImage.loaded {
  display: block;
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 16px;
}

.slide-number {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
}

/* 控制按钮区域 */
.controls {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: white;
  border-bottom: 1px solid var(--border-color);
}

.control-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 56px;
  padding: 12px 24px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.control-btn:hover {
  background: #1976D2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
}

.control-btn:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(33, 150, 243, 0.3);
  background: #1565C0;
}

.control-btn:disabled {
  background: #ccc;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-icon {
  font-size: 20px;
}

/* 提示词区域 */
.notes-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  background: white;
  overflow: hidden;
}

.notes-header {
  margin-bottom: 12px;
}

.notes-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-color);
}

.notes-textarea {
  flex: 1;
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 15px;
  line-height: 1.6;
  resize: none;
  font-family: inherit;
  transition: border-color 0.3s;
}

.notes-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

.notes-textarea::placeholder {
  color: #999;
}

/* 通知提示 */
.notification {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  background: var(--text-color);
  color: white;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  font-size: 14px;
  font-weight: 500;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
  z-index: 1000;
  max-width: 90%;
  text-align: center;
}

.notification.show {
  opacity: 1;
  visibility: visible;
}

.notification.success {
  background: var(--success-color);
}

.notification.error {
  background: var(--error-color);
}

.notification.warning {
  background: var(--warning-color);
}

/* 二维码扫描器 */
.qr-scanner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.3s;
}

.qr-scanner.hidden {
  display: none;
}

.qr-scanner-content {
  position: relative;
  width: 90%;
  max-width: 400px;
  background: white;
  border-radius: 12px;
  padding: 20px;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--error-color);
  color: white;
  border-radius: 50%;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.3s;
}

.close-btn:hover {
  background: #d32f2f;
  transform: rotate(90deg);
}

#qrReader {
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .connection-form {
    flex-direction: column;
  }

  #serverAddress {
    width: 100%;
  }

  .btn-connect, .btn-scan {
    width: 100%;
  }

  .controls {
    flex-direction: column;
  }

  .control-btn {
    width: 100%;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .preview-container {
    flex: 0 0 40%;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  :root {
    --primary-color: #0D47A1;
    --text-color: #000;
    --border-color: #000;
  }

  .control-btn {
    border: 2px solid #000;
  }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #121212;
    --text-color: #e0e0e0;
    --border-color: #333;
  }

  body {
    background-color: var(--bg-color);
  }

  .container {
    background: #1e1e1e;
  }

  .connection-panel {
    background: #1e1e1e;
    border-bottom-color: var(--border-color);
  }

  .controls {
    background: #1e1e1e;
    border-bottom-color: var(--border-color);
  }

  .notes-container {
    background: #1e1e1e;
  }

  .notes-textarea {
    background: #2a2a2a;
    color: var(--text-color);
    border-color: var(--border-color);
  }

  #serverAddress {
    background: #2a2a2a;
    color: var(--text-color);
    border-color: var(--border-color);
  }
}
